﻿@model FCNS.ERP.Models.ErpProduct

@{
    ViewBag.Title = "商品-新增";
    Layout = "~/Views/Shared/_Layout.cshtml"; ;
}

<h2>@ViewBag.Title</h2>
@Scripts.Render("~/bundles/Tabs")
@Styles.Render("~/Content/TabsCss")

<script type="text/javascript">
    $(document).ready(function () {
        $("#tabs").tabs();

        $("#Low").val(0);
        $("#Rent").val(0);
        $("#Deposit").val(0);

        $(".newObjAnoText").click(function () {
            var a = prompt();
            if (a == null || a == '')
                return;

            var dataType = $(this);
            $.post("/Basic/UnitNewAdd",
                {
                    name: a,
                    flag: $(this).attr("data-Type")
                }
                ,
                function (data, status) {
                    if (status == "success") {
                        if (data == "-1") {
                            alert("数据添加异常");
                        }
                        else {
                            if (dataType.attr("data-Type") == 0) {
                                $("#UnitId").append("<option value='" + data + "'>" + a + "</option>");
                                $("#UnitId").val(data);
                            }
                            else if (dataType.attr("data-Type") ==1) {
                                $("#BrandId").append("<option value='" + data + "'>" + a + "</option>");
                                $("#BrandId").val(data);
                            }
                            else if (dataType.attr("data-Type") == 2) {
                                $("#ModelId").append("<option value='" + data + "'>" + a + "</option>");
                                $("#ModelId").val(data);
                            }
                        }
                    }
                    else {
                        alert("操作失败");
                    }
                });
            return true;
        });
    });
</script>


@using (Html.BeginForm("ProductNew", "Basic", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <hr />
        <input type="submit" value="新增" class="btn btn-default" />

        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">常规</a></li>
                <li><a href="#tabs-2">规格/参数</a></li>
                <li><a href="#tabs-3">租赁</a></li>
            </ul>

            <div id="tabs-1">
                <div class="form-group">
                    @Html.LabelFor(model => model.Enable, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        <div class="checkbox">
                            @Html.CheckBoxFor(model => model.Enable, htmlAttributes: new { @checked = "checked" })
                            @Html.ValidationMessageFor(model => model.Enable, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.CategoryProductId, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.DropDownList("CategoryProductId", ViewData["CategoryProduct"] as SelectList, htmlAttributes: new { @class = "form-control" })
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.BrandId, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        <table class="table-condensed">
                            <thead>
                                <tr>
                                    <th>
                                        @Html.DropDownList("BrandId", ViewData["Brand"] as SelectList, htmlAttributes: new { @class = "form-control", @style = "width:300px;" })
                                    </th>
                                    <th>
                                        <a class="newObjAnoText" href="#" data-Type="1"></a>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.ModelId, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        <table class="table-condensed">
                            <thead>
                                <tr>
                                    <th>
                                        @Html.DropDownList("ModelId", ViewData["Model"] as SelectList, htmlAttributes: new { @class = "form-control", @style = "width:300px;" })
                                    </th>
                                    <th>
                                        <a class="newObjAnoText" href="#" data-Type="2"></a>
                                    </th>
                                </tr>
                            </thead>
                        </table> 
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.UnitId, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        <table class="table-condensed">
                            <thead>
                                <tr>
                                    <th>
                                        @Html.DropDownList("UnitId", ViewData["Unit"] as SelectList, htmlAttributes: new { @class = "form-control", @style = "width:300px;" })
                                    </th>
                                    <th>
                                        <a class="newObjAnoText" href="#" data-Type="0"></a>
                                    </th>
                                </tr>
                            </thead>
                        </table> 
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.PurchasePrice, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.PurchasePrice, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.PurchasePrice, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.SalePrice, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.SalePrice, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.SalePrice, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>

            <div id="tabs-2">
                <div class="form-group">
                    @Html.LabelFor(model => model.Barcode, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.Barcode, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.Barcode, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.Low, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.Low, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.Low, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.Summary, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.Summary, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.Summary, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.ImgUrl, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        <input type="file" name="pic" accept="image/png,image/jpg" />
                    </div>
                </div>
            </div>

            <div id="tabs-3">
                <div class="form-group">
                    @Html.LabelFor(model => model.CanRent, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        <div class="checkbox">
                            @Html.CheckBoxFor(model => model.CanRent)
                            @Html.ValidationMessageFor(model => model.CanRent, "", new { @class = "text-danger" })
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.Rent, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.Rent, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.Rent, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.Deposit, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.Deposit, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.Deposit, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>

        </div>

    </div>
}

<div>
    <a class="backToListImg" href="/Basic/Product">返回</a>
</div>
